all files / lib/ screen.js

100% Statements 18/18
100% Branches 2/2
100% Functions 4/4
100% Lines 18/18
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71                            34×                           12×                     11×                                
'use strict';
 
var inherit = require('./utils').inherit;
var Page = require('./page');
var Track = require('./track');
 
/**
 * Initialize new `Screen` facade with `dictionary`.
 *
 * @param {Object} dictionary
 *   @param {string} category
 *   @param {string} name
 *   @param {Object} traits
 *   @param {Object} options
 * @param {Object} opts
 *   @property {boolean|undefined} clone
 */
function Screen(dictionary, opts) {
  Page.call(this, dictionary, opts);
}
 
/**
 * Inherit from `Page`
 */
 
inherit(Screen, Page);
 
/**
 * Get the facade's action.
 *
 * @api public
 * @return {string}
 */
Screen.prototype.action = function() {
  return 'screen';
};
 
Screen.prototype.type = Screen.prototype.action;
 
/**
 * Get event with `name`.
 *
 * @api public
 * @param {string} name
 * @return {string}
 */
Screen.prototype.event = function(name) {
  return name ? 'Viewed ' + name + ' Screen' : 'Loaded a Screen';
};
 
/**
 * Convert this Screen.
 *
 * @api public
 * @param {string} name
 * @return {Track}
 */
Screen.prototype.track = function(name) {
  var json = this.json();
  json.event = this.event(name);
  json.timestamp = this.timestamp();
  json.properties = this.properties();
  return new Track(json, this.opts);
};
 
/**
 * Exports.
 */
 
module.exports = Screen;